<template>
  <div class="common_block_div">
    <el-table v-loading="loading" :data="list">
      <el-table-column label="集合编号" prop="id" width="100" />
      <el-table-column label="项目编号" prop="project_no" width="180" />
      <el-table-column label="项目标题" prop="title" :show-overflow-tooltip="true" width="300" />
      <el-table-column label="提交时间" width="200">
        <template slot-scope="scope">
          {{ scope.row.begin_time }} - {{ scope.row.end_time }}
        </template>
      </el-table-column>
      <el-table-column label="评分时间" width="200">
        <template slot-scope="scope">
          {{ scope.row.pw_df_begin_time }} - {{ scope.row.pw_df_end_time }}
        </template>
      </el-table-column>
      <el-table-column label="提交总数" prop="all_num" width="150" />
      <el-table-column label="审核成功总数" prop="sh_success_num" width="150" />
      <el-table-column label="评分完成总数" prop="pw_complate_num" width="150" />
      <el-table-column label="状态" prop="status_text" width="150" />
      <el-table-column label="操作" width="100px" align="center" fixed="right">
        <template slot-scope="scope">
          <el-button size="mini" type="text" @click="handleResume(scope.row)" v-if="have_auth('/project/delete/huifu')">恢复</el-button>
        </template>
      </el-table-column>
    </el-table>
    <pagination v-show="total > 0" :total="total" :page.sync="queryParams.page" :limit.sync="queryParams.limit"
      @pagination="getList" />
  </div>
</template>

<script>
// 导入项目管理API
import projectApi from "@/api/project";

export default {
  name: 'ProjectRecycleBin',
  data() {
    return {
      loading: true,
      total: 0,
      // 回收站列表数据
      list: [],
      // 查询参数
      queryParams: {
        page: 1,
        limit: 10
      }
    }
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询回收站列表 */
    getList() {
      const _this = this;
      this.loading = true;
      // 使用项目API获取回收站列表
      projectApi.callbackList(this.queryParams).then(function (res) {
        if (res && res.message) {
          _this.list = res.message.data || [];
          _this.total = res.message.total || 0;
        }
        _this.loading = false;
      }).catch(function (error) {
        console.error('获取回收站列表失败:', error);
        _this.loading = false;
      })
    },
    /** 恢复项目 */
    handleResume(row) {
      const _this = this;
      this.$confirm('是否确认恢复该项目?', "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      }).then(function () {
        projectApi.resume({ id: row.id }).then((res) => {
          if (res) {
            _this.getList();
            _this.$message.success('恢复成功');
          }
        }).catch((err) => {
          console.error('恢复项目失败:', err);
          _this.$message.error('恢复失败');
        });
      }).catch(() => { });
    },
  }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped></style>
